package com.strawcom.charmring.bean;

import org.litepal.crud.DataSupport;

import com.strawcom.charmring.bean.http.AlarmResponse;

public class Alert extends DataSupport {
	
	public Alert(){
	}
	
	public Alert(String name,  String msg,double lat, double lng) {
		this.name = name;
		this.lat = lat;
		this.lng = lng;
		this.msg = msg;
	}
	
	private int id;

	/** 用户名称 **/
	private String name;
	
	/** 电话号码 **/
	private String phonenum;
	
	/** 用户自定义头像 **/
	private String icon;
	
	/** 告警位置  */
	private double lat;
	
	private double lng;
	/** 经纬度位置精度*/
	private double acc;
	
	/** 告警时间 **/
	private String date;
	
	/** 告警消息 **/
	private String msg;
	
	public static Alert convertByAlarmResponse (AlarmResponse alarmResponse) {
		Alert alert = new Alert();
		alert.name = alarmResponse.alarmuserinfo.username;
		alert.phonenum = alarmResponse.alarmuserinfo.phoneno;
		alert.icon = alarmResponse.alarmuserinfo.photo;
		alert.msg = alarmResponse.alarminfo.content;
		alert.date = alarmResponse.alarminfo.sendtime;
		alert.lat = alarmResponse.position.latitude;
		alert.lng  =alarmResponse.position.longitude;
		alert.acc = alarmResponse.position.accuracy;
		return alert;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getPhonenum() {
		return phonenum;
	}

	public void setPhonenum(String phonenum) {
		this.phonenum = phonenum;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public double getLat() {
		return lat;
	}

	public void setLat(double lat) {
		this.lat = lat;
	}

	public double getLng() {
		return lng;
	}

	public void setLng(double lng) {
		this.lng = lng;
	}

	public double getAcc() {
		return acc;
	}

	public void setAcc(double acc) {
		this.acc = acc;
	}

	public String getDate() {
		return date;
	}

	public void setDate(String date) {
		this.date = date;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}
	
	@Override
	public boolean equals(Object o) {
		if(o instanceof Alert) {
			Alert t = (Alert) o;
			if(t.phonenum != null && t.phonenum.equals(this.phonenum)){
				return true;
			}
		}
		return false;
	}
	
}
